package com.itheima.jingjie.map.map练习;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class TestMapStudent {
    public static void main(String[] args) {
        HashMap<Student, String> hm = new HashMap<>();
        Student s1 = new Student("小黑", 25);
        Student s2 = new Student("大鹏", 22);
        Student s3 = new Student("小妹", 22);
        hm.put(s1, "江苏");
        hm.put(s2, "北京");
        hm.put(s3, "天津");
        Set<Student> students = hm.keySet();
        for (Student student : students) {
            String s = hm.get(student);
            System.out.println(student + "...." + s);
        }
        System.out.println(".........................");
        Set<Map.Entry<Student, String>> entries = hm.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            Student key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key + "......." + value);
        }
        System.out.println(".........................");
        hm.forEach((Student s, String str) -> {
            System.out.println(s + "....." + str);
        });

        System.out.println(".........................");
        hm.forEach((Student s, String str) -> {
            System.out.println(s + "....." + str);
        });
    }


}
